package com.louis.buddhist.ui.adapter;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.louis.buddhist.R;
import com.louis.buddhist.data.entity.Page;

import java.util.List;

/**
 * Created by fenglei on 2018/4/11.
 */

public class ReadPreviewAdapter extends BaseQuickAdapter<Page, BaseViewHolder> {

    public ReadPreviewAdapter(int layoutResId, @Nullable List<Page> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Page item) {


        ImageView pic = helper.getView(R.id.iv_pic);
        Bitmap bitmap = BitmapFactory.decodeFile(item.getFile().getAbsolutePath());
        pic.setImageBitmap(bitmap);

        helper.setText(R.id.tv_page, item.getPage());

    }
}
